#include "Space.h"
#include <qpainter.h>
#include <qtimer.h>
#include <QtGui>
#include <QPen>

namespace talisman_map
{
	Space::Space(QWidget *parent) :
	  mDescription("") 
	, mNextSpace(0)
	, mPrevSpace(0)
	, mInstruction(0)
{
	setFixedSize(105, 100);
	picture.load("Images\\space2.gif");
}

Space::~Space()	
{
	if (0 != mInstruction)
		delete mInstruction;
}

void Space::resetReferences()
{
	setNextSpace(0);
	setPrevSpace(0);
}


void Space::paintEvent(  QPaintEvent *event)
{
	QPainter painter(this);
	const QColor w (0,255,0);
	painter.setPen(getColor());
	painter.setRenderHint(QPainter::Antialiasing);
	painter.drawImage(0,0,picture);

	if (getInstruction() != 0)
		painter.drawImage(55,50,getInstruction()->getImage());

	QString desc (getDescription().c_str());
	painter.setPen(Qt::black);
	QRect tr(5, 5, 90, 60);
	QFont f = painter.font();
	f.setPointSize(7);
	painter.setFont(f);
	painter.drawText(tr,desc);
}

}